# file:: $Name$
# author::  $Author$
# version:: $Revision$
# date:: $Date$
#
# This source code copyright (C) 2006 by Ralph M. Churchill
# All rights reserved.
#
# Released under the terms of the GNU General Public License
# See LICENSE file for additional information.

require 'engine/command'

# Will eventually be:
# get [quantity] <item> [from <container>]
class Get < Command
    def initialize(executor)
        super(executor,"get","get [quantity] <item>",
              "Attempt to get an item.")
    end
    def execute(args)
        raise UsageException if args.empty?
        quantity = args.shift.to_i if args[0] =~ /(\d)/
        item_name = args.join(' ')
        item = self.executor.room.items.find{|i| i.named?(item_name)}
        unless item.nil?
            GameEngine.instance.do_action(
                Action.new(:attemptgetitem,self.executor,
                           {:item => item,
                            :from => self.executor.room,
                            :quantity => quantity||=1}))
        else
            inform("You don't see any #{item_name} here.")
        end
    end
end
